package com.lebang.model.enums;

/**
 * 资源分类
 * @className SessionStatus
 * @author weizx  
 * @date 2018年6月27日 上午11:52:25
 */
public enum ResourceCategory {
	/**
	 *
	 */
	Menu("菜单", 1),
	MenuItem("菜单项", 2),
	Element("元素", 3);
	
	private String title;
	private int index;
	
	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public int getIndex() {
		return index;
	}

	public void setIndex(int index) {
		this.index = index;
	}

	private ResourceCategory(String title, int index) {
		this.title = title;
		this.index = index;
	}
	
	public ResourceCategory getByIndex(int index) {
		for (ResourceCategory e : ResourceCategory.values()) {
			if (e.index == index) {
				return e;
			}
		}
		return null;
	}
	
	public ResourceCategory getByTitle(String title) {
		if (null == title) {
			return null;
		}
		for (ResourceCategory e : ResourceCategory.values()) {
			if (e.title.equals(title)) {
				return e;
			}
		}
		return null;
	}
}
